extends Node2D

signal subsun
const hang = 9
const lie = 5
const tile_size = 64

onready var Game = get_tree().current_scene.get_node(".")
onready var Sunlabel = get_tree().current_scene.get_node("Sun/Label")

func _ready():
	connect("subsun",get_tree().current_scene.get_node("Sun/Label"),"sub")
	pass

func plant(hang,lie,plant):
	
	pass

func plant2(plant):
	
	pass

# 种植物逻辑
func _on_Area2D_input_event(viewport, event, shape_idx):
	if event is InputEventMouseButton:
		if event.is_pressed() and event.button_index == BUTTON_LEFT:
			if Game.selected_Object.name == "sunflower":
				if Sunlabel.number >= 50:
					var sunflower = Game.SunFlower.instance()
					add_child(sunflower)
					sunflower.global_position = get_global_mouse_position()
					emit_signal("subsun",Game.selected_Object.cost)
					Game.selected_Object.name = ""
					Game.selected_plant.queue_free()
			elif Game.selected_Object.name == "wandou":
				if Sunlabel.number >= 100:
					var wandou = Game.WanDou.instance()
					add_child(wandou)
					wandou.global_position = get_global_mouse_position()
					emit_signal("subsun",Game.selected_Object.cost)
					Game.selected_Object.name = ""
					Game.selected_plant.queue_free()
			elif Game.selected_Object.name == "jinweijianguo":
				if Sunlabel.number >= 50:
					var jg = Game.JianGuo.instance()
					add_child(jg)
					jg.global_position = get_global_mouse_position()
					emit_signal("subsun",Game.selected_Object.cost)
					Game.selected_Object.name = ""
					Game.selected_plant.queue_free()
			pass
	pass # Replace with function body.
